import selfApi from "@/apis/selfApi"
import userStore from "@/store/userStore";
import { defineStore} from "pinia"

export default defineStore('self',{
    state:()=>{
        return { 
            selfBokInfo:[]  as any,
            pageNum:1 as number,
            totalPages:1 as number,
            userID:userStore().info.id as any
        }
    },
    actions:{ 
       
        //获取当前用户的全部博客
         async getAllBokByUid(pageNum:any,u_id:any){
            this.selfBokInfo= (await selfApi.getBokBySelf(pageNum,u_id)).data  as []
            // console.log(this.selfBokInfo);
            this.pageNum= this.selfBokInfo?.currentPage;
            this.totalPages= this.selfBokInfo?.page_count;
            return this.selfBokInfo
         },
        
        
    },
    persist:{
      key:'selfinfo',
      storage:sessionStorage
 }
})